package Coding.file;

import java.io.File;

public class RecursionDir {

    public static void main(String[] args) {

        File dir = new File("./a");
        recursionFolder(dir);

    }

    private static void recursionFolder(File dir) {

        if(dir.isFile()){
            System.out.println("文件不支持递归");
            return;
        }else {

            File[] subs = dir.listFiles();
            for (int i = 0; i < subs.length; i++) {
//                System.out.println(subs[i]);
//                System.out.println(subs[i].getName());

                if(subs[i].isFile()){
                    System.out.println("文件"+subs[i]);
                }else {
                    System.out.println("目录" + subs[i]);
                    recursionFolder(subs[i]);
                }
                
            }
        }
    }
}
